`include "apbslave.v" 
//DHEERAJ KUMAR BISWAS

//`include "sram.v"

module slaveBlock(	clk,
					resetn,
					PADDR,
					PPROT,
                  	PSEL,
					PENABLE,
					PWRITE,
					PWDATA,
                    PSTRB,
                    PREADY,
                    PRDATA,
                    PSLVERR);

	//parameter declarations
	parameter DATA_WIDTH	 = 32;
	parameter MEMORY_WIDTH	 = 1024;
	parameter ADDR_WIDTH   	 = 10; //log2(MEMORY_WIDTH);
	parameter STRB_WIDTH	 = 4; //log2(DATA_WIDTH-8);
	
	input						clk;
	input						resetn;
	input	[ADDR_WIDTH-1:0]	PADDR;
	input						PPROT;
	input						PSEL;
	input						PENABLE;
	input						PWRITE;
	input	[DATA_WIDTH-1:0]	PWDATA;
	input	[STRB_WIDTH-1:0]  	PSTRB;
    output						PREADY;
	output  [DATA_WIDTH-1:0]	PRDATA;
	output 						PSLVERR;

  	wire 	[ADDR_WIDTH-1:0] 	mem_addr; 
  	wire 						mem_write;
  	wire	[STRB_WIDTH-1:0]	mem_strb;
  	wire 	[DATA_WIDTH-1:0] 	mem_wdata;
  	wire 	[DATA_WIDTH-1:0] 	mem_rdata;
  	wire 						mem_rvalid;    //SRAM memory signals

  apbSlaveSramInterface VCSlave(clk,
                             resetn,
                             PADDR,
                             PPROT,
                             PSEL,
                             PENABLE,
                             PSTRB,
                             PWRITE,
                             PWDATA,
                             PREADY,
                             PRDATA,
                             PSLVERR,
                             mem_addr,   //SRAM memory signals
                             mem_write,
                             mem_strb,
                             mem_wdata,
                             mem_rdata,
			     			 mem_rvalid);

	SRAM VCSram(.clk		(clk),
				.rstn		(resetn),
	    		.addr 		(mem_addr),
	   			.write 		(mem_write),
	    		.byte_strb	(mem_strb),
	    		.wdata 		(mem_wdata),
	    		.rdata 		(mem_rdata),
	    		.rvalid 	(mem_rvalid));
 
/*
	function integer log2;
	input integer value;
	begin
		value = value-1;
		for(log2 = 0; value>0; log2=log2+1)
			value = value>>1;
	end
  endfunction
*/
endmodule
